#include <stdio.h>

int substitute(char *str, char oldchar, char newchar)
{
    int count = 0, i;
    for (i = 0; str[i] != '\0'; i++) {
        if (str[i] == oldchar) {
            count++;
            str[i] = newchar;
        }
    }
    return count;
}

int main()
{
    char str[1024], oldchar, newchar;
    while (scanf("%s %c %c", str, &oldchar, &newchar) == 3)
    {
        printf("%d %s\n", substitute(str, oldchar, newchar), str);
    }
    return 0;
}
